Skip to content

[ios] fix pressable with intercepting detector#4041

Open
akwasniewski wants to merge 3 commits intomainfrom
@akwasniewski/ios-fix-buttons-with-virutal-detector
Open

[ios] fix pressable with intercepting detector#4041
akwasniewski wants to merge 3 commits intomainfrom
@akwasniewski/ios-fix-buttons-with-virutal-detector

Conversation

@akwasniewski
Copy link
Copy Markdown
Contributor

@akwasniewski akwasniewski commented Mar 27, 2026

Description

On iOS, when under pressable, we had an intercepting detector handling a nested text gesture, pressable did not activate when we pressed on the part of the text with no virtual gesture attached to it. This PR should fix the issue.

The problem was that when the button was hit-testing its children, it assumed that the gesture recognizer always wanted to receive events (it was only checking whether there was any). The new implementation goes through the list of found recognizers, checking if they want to handle touch at the specified point.

Note: on web the nested text gesture never activates when under a pressable, web needs further care.

Test plan

Tested on the following example

Details
import { Text } from 'react-native';
import {
  GestureHandlerRootView,
  InterceptingGestureDetector,
  Pressable,
  VirtualGestureDetector,
  useTapGesture,
} from 'react-native-gesture-handler';

export default function Reproduction() {
  const innerTap = useTapGesture({
    onActivate: () => {
      'worklet';
      console.log('RNGH: Inner onPress');
    },
  });

  return (
    <GestureHandlerRootView
      style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Pressable
        style={{ width: 100, height: 100, backgroundColor: 'pink' }}
        onPress={() => console.log('RNGH: Pressable onPress')}>
        <InterceptingGestureDetector>
          <Text>
            Outer{' '}
            <VirtualGestureDetector gesture={innerTap}>
              <Text>Inner</Text>
            </VirtualGestureDetector>
          </Text>
        </InterceptingGestureDetector>
      </Pressable>
    </GestureHandlerRootView>
  );
}

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes iOS Pressable activation when an InterceptingGestureDetector under the pressable causes touches to land on nested text views, preventing the outer button from receiving the expected control events.

Changes:

  • Added touchesBegan/Ended/Cancelled overrides on iOS to dispatch UIControl actions when the touch originates from a subview rather than the button itself.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@j-piasecki j-piasecki force-pushed the @akwasniewski/ios-fix-buttons-with-virutal-detector branch from 9928ede to 1d394d9 Compare April 3, 2026 12:54
@j-piasecki j-piasecki force-pushed the @akwasniewski/ios-fix-buttons-with-virutal-detector branch from 1d394d9 to 81d2554 Compare April 3, 2026 12:57
@j-piasecki j-piasecki requested a review from Copilot April 3, 2026 12:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants